import {
  CDNFileMd5Exist,
  CDNFileType,
} from './'

export interface CDNDownloadDataRequest {
  ver: number,
  weixinnum: number,
  seq: number,
  clientversion: number,
  clientostype: string,
  authkey: Buffer,
  nettype: number,
  acceptdupack: number,
  safeproto: number,
  filetype: CDNFileType,
  wxchattype: number,
  fileid: string,
  lastretcode: number,
  ipseq: number,
  wxmsgflag: number | null,
  wxautostart: number,
  downpicformat?: number,
  largesvideo?: number,
  sourceflag?: number,
  rangestart: number,
  rangeend: number,
}

export interface CDNDownloadDataResponse {
  ver: number,
  rangestart: number,
  rangeend: number,
  totalsize: number,
  seq: number,
  retcode: number,
  substituteftype: number,
  rsppicformat: number,
  retrysec: number,
  isretry: number,
  isoverload: number,
  isgetcdn: number,
  'x-ClientIp': string,
  filedata: Buffer,
}

export interface CDNCheckMd5Request {
  ver: number,
  weixinnum: number,
  seq: number,
  clientversion: number,
  clientostype: string,
  authkey: Buffer,
  nettype: number,
  acceptdupack: number,
  filetype: CDNFileType,
  safeproto: number,
  enablehit: number,
  filemd5: string,
  largesvideo: number,
  wxchattype: number,
  advideoflag: number,
  touser: string,
}

export interface CDNCheckMd5Response {
  ver: number,
  seq: number,
  existflag: CDNFileMd5Exist,
  aeskey?: Buffer,
  fileid?: string,
  midimglen?: number,
  cachesize?: number,
  retcode: number,
}

export interface CDNUploadDataRequest {
  ver: number,
  weixinnum: number,
  seq: number,
  clientversion: number,
  clientostype: string,
  authkey: Buffer,
  nettype: number,
  acceptdupack: number,
  safeproto: number,
  filetype: CDNFileType,
  wxchattype: number,
  lastretcode: number,
  ipseq: number,
  hasthumb: number,
  touser: string,
  compresstype: number,
  nocheckaeskey: number,
  enablehit: number,
  existancecheck: number,
  apptype: number,
  filekey: string,
  totalsize: number,
  rawtotalsize: number,
  localname: string,
  thumbtotalsize: number,
  rawthumbsize: number,
  rawthumbmd5: string | null,
  encthumbcrc: number,
  largesvideo: number,
  sourceflag: number,
  advideoflag: number,
  rangestart: number,
  rangeend: number,
  filedatamd5: string,
  filemd5: string,
  rawfilemd5: string,
  blockmd5: string,
  filedata: Buffer,
}

export interface CDNUploadDataResponse {
  ver: number,
  filekey: string,
  rangestart: number,
  rangeend: number,
  seq: number,
  retcode: number,
  existflag: CDNFileMd5Exist,
  fileid?: string,
  retrysec: number,
  isretry: number,
  isoverload: number,
  isgetcdn: number,
  'x-ClientIp': string,
}

export interface FileCache {
  fileId: string,
  aesKey: Buffer,
  timestamp: number,
}
